#!/bin/sh

# $Id: miniupnpd.init.d.script,v 1.2 2007/09/23 16:11:12 nanard Exp $
# MiniUPnP project
# author: Thomas Bernard
# website: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/

# Re-created from scratch by the SlackBuild's author Pablo Oses <opablo@gmail.com>
# using the simple service start/stop/restart script template

SERVICENAME="miniupnpd"
CONFIGPATH=/etc/miniupnpd
BINPATH=/usr/sbin

# Start service:
start()
{
  echo -n "Starting $SERVICENAME..."
  ${CONFIGPATH}/iptables_init.sh > /dev/null 2>&1
  ${BINPATH}/miniupnpd -f ${CONFIGPATH}/miniupnpd.conf
  echo
}

# Stop service:
stop()
{
  echo -n "Stopping ${SERVICENAME}... "
  killall miniupnpd
  ${CONFIGPATH}/iptables_removeall.sh > /dev/null 2>&1
  echo
}

# Restart service:
restart()
{
  stop
  sleep 1
  start
}

case "$1" in
  'start')
    start
    ;;
  'stop')
    stop
    ;;
  'restart')
    restart
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
